select id from role_info where id in(select role_id from admin_role where admin_id=22);


select * from admin_info ai inner join admin_role ar on ai.id=ar.admin_id 
				inner join role_info ri on ri.id=ar.role_id where ai.id=22;



select * from account;

select * from(
	select a.*,rownum r
	from admin_info a
	where rownum<?
)where r>?
and id in(
	select admin_id from admin_role
	where role_id=1
)
and id in(
	select a.admin_id from role_privilege p
	inner join role_info r
	on r.id=p.role_id
	inner join admin_role a
	on a.role_id = r.id
	where p.privilege_id = ?
);
==========================
select * from (select a.*,rownum r from admin_info a where 1=1
 and id in( select admin_id from admin_role where role_id=1 )
 and id in (select a.admin_id from role_privilege p inner join role_info r 
 on r.id=p.role_id inner join admin_role a on a.role_id = r.id 
 where p.privilege_id = 1 )
rownum<9 )where r>0;
==========================
select * from ( select a.*,rownum r from admin_info a where 1=1 
--and id in( select admin_id from admin_role where role_id=?) 
--and id in( select a.admin_id from role_privilege p inner join role_info r 
--on r.id=p.role_id inner join admin_role a on a.role_id=r.id 
--where p.privilege_id=?) 
and rownum<6) where r>0;
==========================
select * from (
	select a.*,rownum r
	from account_hyg a
	where 1=1
	and status=1
	and rownum<6
) where r>0

select * from COST_hyg order by unit_cost;

select * from role_info;
select * from admin_info;
select * from account_hyg;
select * from service_hyg;
select * from cost_hyg;
select * from all_tables;
select * from admin_role;
select * from role_privilege;

select admin_info_seq.nextval from dual;
create sequence admin_info_seq;

insert into admin_role values(1000,1);
insert into admin_info values(1003,'test',123,'Tom',1234567,'adsf@qq.com',sysdate);

create sequence role_seq
start with 1000;

select * from account;

select role_seq.nextval from dual;

select * from role;
select * from role_info;
select * from role_privilege;

select privilege_id from role_privilege where role_id=2;
//账务账号开通
update account_hyg set status=0;

select * from role_privilege;

insert into account_hyg values(account_seq.nextval,'22','123','123','0',sysdate,null,null,'123','321022200010012112','1999-09-09','0','2','123','123','123','123','123',null,null)

ALTER SESSION SET NLS_DATE_FORMAT = 'yyyy mm dd hh24:mi:ss';

create swquence account_seq1;

select role_seq.nextval from dual;


select service_seq.nextval from dual; 



update account_hyg set status='1',pause_date=null where id=96;


select * from (
	select a.*,rownum r
	from 
	(select * from cost_hyg order by unit_cost desc) a
	where 1=1
	and rownum<6
) where r>0



select * from (
	select s.*,
	a.IDCARD_NO,a.real_name,
	c.name,c.descr,rownum r
	from service_hyg s 
	inner join account_hyg a
	on s.account_id=a.id
	inner join cost_hyg c
	on s.cost_id=c.id
	where 1=1
	and rownum<10
)where r>0;


select * from account_hyg
where id in (
	select account_id from service_hyg
	where id=?
)

select * from service_hyg;